using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RoleCtr : MonoBehaviour
{

    public float upSpeed = 2f;
    public float downSpeed = 0.3f;
    public float waitTime = 0.5f;
    private float curWaitTime;
    private bool hasPointDown = true;

    private float curY = 0;

    void Awake()
    {

    }

    // Start is called before the first frame update
    void Start()
    {
        curWaitTime = 0;
    }

    // Update is called once per frame
    void Update()
    {
        curWaitTime += Time.deltaTime;
        curY = 0;
        if (Input.GetKeyDown(KeyCode.Space))
        {
            hasPointDown = true;
            curWaitTime = 0;
            curY = Time.deltaTime * upSpeed;
        }

        if (curWaitTime >= waitTime)
        {
            hasPointDown = false;
        }

        if (hasPointDown)
        {
            this.transform.Translate(Vector3.up * curY);
        }
        else
        {
            curY = Time.deltaTime * downSpeed;
            this.transform.Translate(Vector3.down * curY);
        }


    }
}
